import { reqSearchInfoData } from '@/api'

const state = {
    searchInfo: {}
}

const actions = {
    async getSearchInfoData({ commit }, searchParams) {
        const result = await reqSearchInfoData(searchParams)
        // console.log('搜索数据', result);
        if (result.code === 200) {
            commit('SAVE_SEARCH_INFO_DATA', result.data)
        } else {
            console.log(result.message);
        }
    }
}

const mutations = {
    SAVE_SEARCH_INFO_DATA(state, payload) {
        state.searchInfo = payload
    }

}

const getters = {
    goodsList(state) {
        return state.searchInfo.goodsList
    },
    attrsList(state) {
        return state.searchInfo.attrsList
    },
    trademarkList(state) {
        return state.searchInfo.trademarkList
    },
    total(state) {
        return state.searchInfo.total
    }
}

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}